package com.huike.review.mapper;


import com.huike.review.pojo.Review;
import org.apache.ibatis.annotations.*;

import java.util.List;


/**
 * Mybatis复习的Mapper层
 */
public interface MybatisReviewMapper {
    /**======================================================新增======================================================**/
    @Insert("insert into mybatis_review (name,age,sex) values (#{name},#{age},#{sex})")
    int saveData(@Param("name") String name,@Param("age") String age,@Param("sex") String sex);

    @Insert("insert into mybatis_review(name,age,sex) values (#{name},#{age},#{sex})")
    int saveDataByPojo(Review data);

    /**======================================================删除======================================================**/

    @Delete("delete from mybatis_review where id=#{id}")
    int removeData(Long id);

    /**======================================================修改======================================================**/
    @Update("update mybatis_review set name=#{name},age=#{age},sex=#{sex} where id=#{id}")
    int updateData(Review review);

    /**======================================================简单查询===================================================**/
    //根据id查询
    @Select("select id,name,age,sex,create_by as createBy,create_time as createTime,update_time,update_user as updateBy from mybatis_review where id=#{id}")
    Review getById(@Param("id") Long id);

    //分页查询
    @Select("select id,name,age,sex,create_by as createBy,create_time as createTime,update_time ,update_user as updateBy from mybatis_review")
    List<Review> getDadaByPage();
}
